package Demo02;

public class Person {
    private int age;
    public Person(){
        this.age = 0;
    }
public void setAge(int age){
        if (age >= 0 && age<=120){
            this.age=age;
            System.out.println("年龄设置成功，年龄为"+this.age);
        }else {
            System.out.println("年龄不合法");
        }
}
}
